package com.module.prms.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import base.dao.GenericHibernateDao;

import com.module.prms.vo.PrmsUserOrg;




public class UserOrgDao extends GenericHibernateDao<PrmsUserOrg, String> {
	
	private UserOrgDao(){}
	
	private static UserOrgDao dao;
	
	public synchronized static UserOrgDao getInstance(){
		if(dao == null )
			dao = new UserOrgDao();
		return dao;
	}
	
	/**
	 * 用户组织列表
	 * huhui 2011-07-30
	 * @param bean  用户实体bean
	 * @param start 数据起始值
	 * @param limit 查询数量
	 * @return Page
	 */
	
    public List getList(Session session,String userid){
    	List userorg = new ArrayList();
        StringBuffer sb = new StringBuffer();
        sb.append("from PrmsUserOrg as obj where obj.cuserId=?");
        //String sql="select * from prms_user";
        Query query = session.createQuery(sb.toString());
        query.setString(0, userid);
        userorg = query.list();
        return userorg;
    }
    
    public List<String> getOrgUser(Session session,String orgId){
    	String hql = "select cuserId from PrmsUserOrg where corgId in("+orgId+")";
    	 Query query = session.createQuery(hql);
    	 return query.list();
    }

	

}
